package jacky.lanlan.song.collection;

import java.util.*;

/**
 * {@code Enumeration} 到 {@code Iterable} 的适配器。
 * 
 * @author Jacky.Song
 */
public class IterableAdapter<E> implements Iterable<E> {
	private Iterator<E> iter;
	
	public IterableAdapter(Enumeration<E> enumeration) {
		List<E> list = new ArrayList<E>();
		while (enumeration.hasMoreElements()) {
			E e = enumeration.nextElement();
			list.add(e);
		}
		this.iter = list.iterator();
	}
	
	@Override
	public Iterator<E> iterator() {
		return iter;
	}
	
}
